package com.fishing.controller;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fishing.entity.OperLog;
import com.fishing.service.OperLogService;

import QL.QLClient;

@Controller
public class SystemController {

	@Autowired
    private OperLogService operlogService;
	
	private static QLClient client = new QLClient();
	
	@ResponseBody
	@RequestMapping(value="Operate/query", method=RequestMethod.POST, produces="text/html")
	public Map<String,Object> query (HttpServletRequest request, String PageIndex, String PageCount) throws Exception {
		Map<String,Object> map = new HashMap<String, Object>();
		List<OperLog> operLog = this.operlogService.selectAll(PageIndex, PageCount);
		int count = this.operlogService.selectCount();
		for (int i = 0;i < operLog.size();i++) {
			operLog.get(i).setEventexplain(operLog.get(i).getEventexplain() == null ? "0" : operLog.get(i).getEventexplain());
			operLog.get(i).setUserid(operLog.get(i).getUserid() == null ? 0 : operLog.get(i).getUserid());
		}
		map.put("status", "200");
		map.put("message", "");
		map.put("count", count);
		map.put("data", operLog);
		return map;
	}
}
